/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package guiexample;

import java.awt.geom.Path2D;

public abstract class Vehicle {

    static final double velocityIncr = 3.5;
    static final double angleIncr = 3;
    private double x;
    private double y;
    private double width;
    private double height;
    private double angle;
    private Velocity velocity;
    private Rotation rotation;

    /**
     * @return the x
     */
    public Vehicle() {
        velocity = Velocity.NONE;
        angle = 0;
    }

    public void updateState() {
        if (velocity == Velocity.FORWARD) {
            x += Math.sin(angle) * velocityIncr;
            y -= Math.cos(angle) * velocityIncr;
        }

        if (velocity == Velocity.BACKWARD) {
            x -= Math.sin(angle) * velocityIncr;
            y += Math.cos(angle) * velocityIncr;
        }

        if (rotation == Rotation.RIGHT) {
            angle += angleIncr;
        }

        if (rotation == Rotation.LEFT) {
            angle -= angleIncr;
        }

        if (angle < -360 || angle > 360)
            angle = 0;
    }

    public double getX() {
        return x;
    }

    /**
     * @param x the x to set
     */
    public void setX(double x) {
        this.x = x;
    }

    /**
     * @return the y
     */
    public double getY() {
        return y;
    }

    /**
     * @param y the y to set
     */
    public void setY(double y) {
        this.y = y;
    }

    /**
     * @return the width
     */
    public double getWidth() {
        return width;
    }

    /**
     * @param width the width to set
     */
    public void setWidth(double width) {
        this.width = width;
    }

    /**
     * @return the height
     */
    public double getHeight() {
        return height;
    }

    /**
     * @param height the height to set
     */
    public void setHeight(double height) {
        this.height = height;
    }

    public double getAngle() {
        return angle;
    }

    public void setAngle(double angle) {
        this.angle = angle;
    }

    public void setVelocity(Velocity v) {
        velocity = v;
    }

    public Velocity getVelocity() {
        return velocity;
    }

    public Rotation getRotation() {
        return rotation;
    }

    public void setRotation(Rotation rotation) {
        this.rotation = rotation;
    }
}

enum Velocity {

    FORWARD, BACKWARD, NONE;
};

enum Rotation {

    RIGHT, LEFT, NONE;
};
